#include "Queue.h"

QueueNode* QueueNodeCreate() {
	QueueNode* Node = (QueueNode*)malloc(sizeof(QueueNode));
	Node->treeNode = NULL;
	Node->next = NULL;
	return Node;
}


QueueNode* EnQueue(QueueNode* obj, BTNode* x) {
	if (obj== NULL) {
		QueueNode* Node = QueueNodeCreate();
		Node->treeNode = x;
		return Node;
	}
	QueueNode* Node = QueueNodeCreate();
	Node->treeNode = x;
	QueueNode* tmp = obj;
	while (tmp->next != NULL) {
		tmp = tmp->next;
	}
	tmp->next = Node;
	Node->next = NULL;
	return obj;
}

QueueNode* DeQueue(QueueNode* obj) {
	if (obj == NULL)
		return NULL;
	QueueNode* tmp = obj;
	QueueNode* Head = obj->next;
	free(tmp);
	tmp = NULL;
	return Head;
}

int isQueueEmpty(QueueNode* obj) {
	return obj == NULL;
}

void QueueDestory(QueueNode* obj) {
	while (obj != NULL) {
		QueueNode* tmp = obj;
		obj = obj->next;
		free(tmp);
		tmp = NULL;
	}
}